package cn.com.ddapp.ddm.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.LinearLayout;

import cn.com.ddapp.ddm.R;


public class FirstStartActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_allstart);
        LinearLayout start_ll= (LinearLayout) findViewById(R.id.start_ll);

//        Handler x = new Handler();
//        x.postDelayed(new splashhandler(), 2000);
      final   AlphaAnimation aa = new AlphaAnimation(1.0f,0.8f);
//        ScaleAnimation ss=new ScaleAnimation(1.0f,0.5f);
        aa.setDuration(2000);
        aa.setFillAfter(true);
        start_ll.startAnimation(aa);
        aa.setAnimationListener(new Animation.AnimationListener()
        {
            @Override
            public void onAnimationEnd(Animation arg0) {
                redirectTo();
            }
            @Override
            public void onAnimationRepeat(Animation animation) {}
            @Override
            public void onAnimationStart(Animation animation) {}

        });
        start_ll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(FirstStartActivity.this, AdActivity.class);
                aa.cancel();
                startActivity(intent);
            }
        });
    }
    private void redirectTo(){
        Intent intent = new Intent(this, AdActivity.class);
        startActivity(intent);
        finish();
    }
//    class splashhandler implements Runnable {
//        public void run() {
//            startActivity(new Intent(getApplication(), MainActivity.class));
//            FirstStartActivity.this.finish();
//        }
//    }

//    public static void startIntent(Context context, Class class1) {
//        Intent intent = new Intent(context, class1);
//        context.startActivity(intent);
//    }

}
